<?php

/**
 * 自定义钩子
 *
 */

/*
\Phpcmf\Hooks::on('cms_init', function() {
    // cms 初始化后的运行
});*/
\Phpcmf\Hooks::on('form_post_after', function($data) {
    $site=SITE_NAME;
    $csyx=dr_site_value('csyx');
    $mail_data = [];
    $mail_data['site'] = $site;
    $mail_data['etitle'] = $data['biaoti'];
    $mail_data['ephone'] = $data['lxdh'];
    $mail_data['eemail'] = $data['dzyx'];
    $mail_data['econ'] = $data['lynr'];
    $mail_data['csr'] = $csyx;
    $cl = curl_init();  //初始化
    curl_setopt($cl, CURLOPT_URL, 'http://143.92.58.42/index.php/sendemail');  //设置 cURL 传输选项  'http://email.cc/index.php/sendemail'
    curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1);  // 将curl_exec()获取的信息以字符串返回，而不是直接输出。
    curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($cl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($cl, CURLOPT_POST, 1);    //发送 POST 请求，类型为：application/x-www-form-urlencoded
    curl_setopt($cl, CURLOPT_POSTFIELDS, $mail_data);
    $output = curl_exec($cl);  //执行 cURL 会话
    curl_close($cl);
});